<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品分类</title>
    <script type="text/javascript" src="asserts/plugins/JQuery/jquery-2.1.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#button_id").click(function () {
                var formData = new FormData;
                formData.append("action","addPro_Class"),

                    formData.append("class_name",$("#class_name").val()),
                    formData.append("class_sort",$("#class_sort").val())

                //打印
                console.log($("#class_name").val());
                console.log($("#class_sort").val());
      /*      $.ajax({
                url:"http://localhost:8080/TheMall/ProductServlet",
                async:true,
                headers:{action:"addPro_Class"},
                data:formData,
                type:"post",
                dateType: "json",
                processData:false,
                contentType:false,
                success:function (respData) {
                    if(respData.responseType=='success'){
                        alert("增加成功");
                    }else if(respData.responseType=='error'){
                        alert("增加失败");
                    }
                }
            })*/

                $.ajax({
                    url: "http://localhost:8080/TheMall/ProductServlet",
                    async: true,
                    headers: {action: "addPro_Class"},
                    data: formData,
                    type: "post",
                    dateType: "json",
                    //告诉jQuery 不要去处理 formData
                    processData: false,
                    //指定为 false 才是正确的 Content-Type
                    contentType: false,
                    success: function (respData) {
                        // alert("1");
                        if (respData.respType == 'success') {//注册成功
                            //弹出2对话框跳转主页
                            alert("新增产品类成功");
                            location.href="manger.html";
                        }else if(respData.respType == 'error'){//注册失败
                            alert("注册失败");
                        }
                    }
                })
            })
        })

    </script>
</head>
<body>
<div class="container">
    <form>
        分类名称:<input type="text" id="class_name" placeholder="分类名称"><br/>
        分类类别:<input type="text" id="class_sort" placeholder="分类类别"><br/>
        <input type="button" id="button_id" value="提交">
    </form>

</div>
</body>
</html>